package com.gmq.chapter01;

/**
 * Created by gmq on 2017/08/08.
 * 1、线程具有随机性
 * 自定义线程类，继承Thread
 *
 * @version 1.0
 * @since 2017/08/08 15:25
 */
public class MyThread01 extends Thread {

    @Override
    public void run() {
        try {
            for (int i=0; i < 10; i++) {
                int time = (int) (Math.random() * 1000);
//                System.err.println("time: " + time);
                Thread.sleep(time);
                System.out.println("run= " + Thread.currentThread().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
